/**
 * Thinking in java 
 *  2018/08/01
 */
package com.dzb.bioclient;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;


/**
 * @author dzb
 * @date 2018年8月15日 上午10:43:03
 * @description  
 * @version 1.0.0
 */
public class TimeClient {
	
	
	public static void main(String[] args) {
		ServerSocket server =null;
		Socket socket=null;
		int port= 8080;//定义端口
		if(args!=null&&args.length>0){
			port = Integer.valueOf(port);
		}
		
		BufferedReader in=null;
		PrintWriter out = null;
		
		try {
			socket = new Socket("127.0.0.1", port);
			in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
			out = new PrintWriter(socket.getOutputStream(),true);
			out.println("query time order");
			System.out.println("send order2 server success !");
			String rsp =in.readLine();
			System.out.println("Now is :"+rsp);
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			if(out!=null){
				out.close();
				out =null;
			}
			if(in!=null){
				try {
					in.close();
					
				} catch (IOException e1) {
					e1.printStackTrace();
				}
				in  =null;
			}
			
			if(socket!=null){
				try {
					socket.close();
				} catch (IOException e1) {
					e1.printStackTrace();
				}
			    socket=null;
			}
		}
		
	}

}
